﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Newtonsoft.Json;

public partial class _Default : System.Web.UI.Page
{
    public string str02 = "";  //名站导航
    public string str03 = "";  //分类站点
    public string str04 = "";  //主力资金龙虎榜
    public string str05 = "";  //主力资金龙虎榜
    public string str06 = "";  //主力资金龙虎榜

    protected void Page_Load(object sender, EventArgs e)
    {
        str02 = Show名站导航();
        str03 = Show分类站点();
        str04 = Show导航(19, 10);
        str05 = Show导航(20, 21);
        str06 = Show导航(21, 15);
    }


    protected string Show名站导航()
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            Basic b = new Basic();
            string str = OperMethod.GetPageByUrl(b.jsonUrl + "siteurl/siteurl.ashx?ac=01&cid=18&n=30", "gb2312");
            SiteTypeEnty obj = new SiteTypeEnty();
            if (!String.IsNullOrEmpty(str))
                obj = JsonConvert.DeserializeObject<SiteTypeEnty>(str);
            if (obj != null)
            {
                sb.AppendFormat("<ul class=\"right_main1\">");
                foreach (var m in obj.lst)
                {
                    sb.AppendFormat("<li><a href=\"{0}\" target=\"_blank\"><span {2}>{1}</span></a></li>", m.SiteUrl, m.SiteName, OTO.AddClass(m.Weight));
                }
                sb.AppendFormat("</ul>");
            }
        }
        catch
        { }
        return sb.ToString();
    }


    protected string Show分类站点()
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            Basic b = new Basic();
            string str = OperMethod.GetPageByUrl(b.jsonUrl + "siteurl/siteurl.ashx?ac=02&cid=17&n=5", "gb2312");
            List<SiteTypeEnty> obj = new List<SiteTypeEnty>();
            if (!String.IsNullOrEmpty(str))
                obj = JsonConvert.DeserializeObject<List<SiteTypeEnty>>(str);
            for (int i = 0; i < obj.Count; i++)
            {
                string _class = "class=\"bg_gray\"";
                if (i % 2 == 0)
                    _class = "";
                sb.AppendFormat("<li {0}>", _class);
                sb.AppendFormat("<ol class=\"rmain_one\">");
                sb.AppendFormat("<li class=\"w90\"><a href=\"fenlei.aspx?cid={0}\" target=\"_blank\">[{1}]</a></li>", obj[i].cid, obj[i].ClassName);
                if (obj[i].lst != null)
                {
                    for (int j = 0; j < obj[i].lst.Count; j++)
                    {
                        sb.AppendFormat("<li class=\"w150\"><a href=\"{0}\" target=\"_blank\"><span {2}>{1}</span></a></li>", obj[i].lst[j].SiteUrl, obj[i].lst[j].SiteName, OTO.AddClass(obj[i].lst[j].Weight));
                    }
                if (obj[i].lst.Count > 4)
                    sb.AppendFormat("<li><a href=\"fenlei.aspx?cid={0}\">更多>></a></li>", obj[i].cid);
                }
                sb.AppendFormat("</ol>");
                sb.AppendFormat("</li>");
            }
        }
        catch
        { }
        return sb.ToString();
    }


    protected string Show导航(int cid, int? num)
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            Basic b = new Basic();
            string str = OperMethod.GetPageByUrl(b.jsonUrl + "siteurl/siteurl.ashx?ac=01&cid=" + cid + "&n=" + num + "", "gb2312");
            SiteTypeEnty obj = new SiteTypeEnty();
            if (!String.IsNullOrEmpty(str))
                obj = JsonConvert.DeserializeObject<SiteTypeEnty>(str);
            if (obj != null)
            {
                foreach (var m in obj.lst)
                {
                    sb.AppendFormat("<li><a href=\"{0}\" target=\"_blank\"><span {2}>{1}</span></a></li>", m.SiteUrl, m.SiteName, OTO.AddClass(m.Weight));
                }
            }
        }
        catch
        { }
        return sb.ToString();
    }

}